package com.gis.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.service.annotation.DeleteExchange;
import org.springframework.web.service.annotation.GetExchange;
import org.springframework.web.service.annotation.HttpExchange;
import org.springframework.web.service.annotation.PostExchange;
import org.springframework.web.service.annotation.PutExchange;
import com.gis.entity.GeoServerStyle;
import com.gis.entity.SLDStyle;
import com.gis.result.ResponseResult;

import lombok.extern.slf4j.Slf4j;

@Service
@HttpExchange(url = "/styles")
public interface GeoServerRestApi {

    /**
     * 创建样式
     *
     * @param styleName    样式名称
     * @param styleContent 样式内容
     * @return 是否创建成功
     */
    @PostExchange(contentType = "application/json")
    String createStyle(@RequestBody Map<String, GeoServerStyle> style);

    @PutExchange(url = "/{style}", contentType = "application/vnd.ogc.sld+xml")
    void modifyStyle(@PathVariable String style, @RequestBody String sldStyle);

    @PutExchange(url = "/{style}", contentType = "application/json")
    void modifyStyle(@PathVariable String style, @RequestBody Map<String, GeoServerStyle> sldStyle);

    @DeleteExchange(url = "/{style}")
    void deleteStyle(
            @PathVariable String style,
            @RequestParam boolean purge,
            @RequestParam boolean recurse);

    default void deleteStyle(@PathVariable String style) {
        System.out.println("deleteStyle");
        this.deleteStyle(style, true, true);
    }

    @GetExchange(url = "/{style}", accept = "application/vnd.ogc.sld+xml; charset=UTF-8")
    String detailStyle(@PathVariable String style);

    @GetExchange(url = "", accept = "application/json")
    Map<String, Object> listStyles();

    @GetExchange
    String showDefaultStyle(String layerName);
}
